<?php

namespace app\command;

use app\admin\model\Channel;
use app\admin\model\Custom;
use app\admin\model\Maint;
use app\admin\model\Other;
use app\admin\model\Project;
use app\admin\model\ProjectModel;
use app\admin\model\Scenic;
use app\admin\model\Taobao;
use app\api\model\MemberVipCard;
use ba\ScenicApi;
use think\console\Command;
use think\console\Input;
use think\console\Output;

class SyncScenic extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('SyncScenic');
        // 设置参数
        $this->setDescription('更新用户会员状态')->setHelp("php think SyncScenic");
    }

    protected function execute(Input $input, Output $output)
    {
        $output->writeln('开始执行');
        $model = (new Scenic());

        $map[] = ['scenic_id','!=',0];
//        $map[] = ['scenic_id','=','poi364'];
        $list =$model->where($map)->field('id,scenic_id,cover')->select();
       foreach ($list as $val){
           if(strpos($val['cover'],'http') !== false){
               $row = (new ScenicApi())->getDetail($val['scenic_id']);
               if(!$row) continue;
               $model->where(['id' => $val['id']])->update(['cover' => $row['defaultPic']]);
               echo $val['scenic_id']."\n";
           }
       }

        $output->writeln('结束执行');

    }
}